using AspNetMvc.Entities;
using AspNetMvc.Models;
using CoreVirtuoso.Config;
using Infrastructure.Events.Interfaces;
using WebGuiMvc.Helpers;

namespace AspNetMvc.Helpers
{
   public class EventTypeAndCategoriesListsHelper
   {
      public static void Fill(EventForEditing viewEvent,
         IEventsOntologyClassesService eventsOntologyClassesService,
         string language)
      {
         var eventTypes = eventsOntologyClassesService.GetClassesTree(EventsOntologyUris.EventTypeClassUri, language);
         viewEvent.EventTypesList = HierarchyHelper.GetHierarchyAsList(eventTypes, viewEvent.Event.Type, EventViewType.Create);

         var eventCategories = eventsOntologyClassesService.GetClassesTree(EventsOntologyUris.EventCategoryClassUri,
                                                                         language);

         if (viewEvent.Event.Categories.Count == 0)
            viewEvent.EventCategoriesLists.Add(HierarchyHelper.GetHierarchyAsList(eventCategories, null, EventViewType.Create));
         else
            foreach (var category in viewEvent.Event.Categories)
               viewEvent.EventCategoriesLists.Add(HierarchyHelper.GetHierarchyAsList(eventCategories, category, EventViewType.Create));
      }
   }
}